/*--------------------------------------------------------------------------
    This source file is part of Abraxas Game Engine
    For the latest info, see http://code.google.com/abraxasge/
    Copyright (C) 2009, Andrew LeRoy <aleroy@member.igda.org>
    ---

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1301, USA.
--------------------------------------------------------------------------*/
#ifndef _Abx_LogManager_hpp_
#define _Abx_LogManager_hpp_

//#include "AbxPlatform.hpp"
#include "AbxPrerequisites.hpp"
#include "AbxLongevity.hpp"
#include "AbxLog.hpp"
#include "loki/Singleton.h"


namespace Abx
{
    class _AbxExport LogManagerImpl
    {
      public:
        LogManagerImpl();
        ~LogManagerImpl();
        
        void startup();
        void shutdown();

        Log* createLog(String const& name, bool makeDefault=false, 
                       LogDest writeTo=LOG_DEST_DEFAULT,
                       LogLevel level=LOG_LVL_DEFAULT,
                       LogEntryType entryTypes=LOG_ENTRY_DEFAULT);
        
        Log* getLog(String const& name) const;
        Log* getDefaultLog() const;
        Log* setDefaultLog(Log* log);
        
        void setLogLevel(LogLevel level);
        void setLogEntryTypes(LogEntryType entryTypes);

        void logMessage(String const& message, LogEntryType entryType=LOG_ENTRY_MESSAGE);
        Log::Stream stream(LogEntryType entryType=LOG_ENTRY_MESSAGE);
        
        void destroyLog(String const& name);
        void destroyLog(Log* log);
        
      private:
        typedef std::map<String, Log*, std::less<String> >    LogList;
        LogList logs_;

        Log* defaultLog_;
    };
    
    inline uint32 GetLongevity(LogManagerImpl*) { return 97; };
    //inline uint32 GetLongevity(LogManagerImpl*) { return Longevity::SLT_LOG_MGR; };
    
    typedef Loki::SingletonHolder< LogManagerImpl,
                                   Loki::CreateUsingNew,
                                   Loki::SingletonWithLongevity
                                 > LogManager;
} // namespace Abx

#endif // _Abx_LogManager_hpp_
